package Practice.String;

import java.util.Locale;
import java.util.Random;
import java.util.Scanner;

public class YanZhengMa {
    public static void main(String[] args) {
        Scanner scanner =new Scanner(System.in);
        Random random = new Random();
        String ma = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRESTUVWXYZ0123456789";

        String s = "";
       // StringBuilder b = new StringBuilder(s);
        //int a = ma.length();
        //System.out.println(a);
        for (int i = 0; i < 4; i++) {
            char c = ma.charAt(random.nextInt(ma.length()));
            //StringBuilder builder = new StringBuilder(c);
            s += c;//builder.append(c);

        }
        System.out.println(s+"请输入验证码");
        String guess = scanner.next();
        String up = guess.toUpperCase();
        String up1 = s.toUpperCase();
        if (up.equals(up1)){
            System.out.println("验证成功");
        }else {
            System.out.println("验证失败,程序退出");
        }




        //System.out.println(s);

    }
}
